{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "tags": [
     "remove-cell"
    ]
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "if not any(path.endswith('textbook') for path in sys.path):\n",
    "    sys.path.append(os.path.abspath('../../..'))\n",
    "from textbook_utils import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "tags": [
     "remove-cell"
    ]
   },
   "outputs": [],
   "source": [
    "# inspections\n",
    "insp = pd.read_csv(\"data/inspections.csv\")\n",
    "\n",
    "# violations\n",
    "viol = pd.read_csv(\"data/violations.csv\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "(ch:wrangling_transformations)=\n",
    "# Transformations and Timestamps\n",
    "\n",
    "Sometimes a feature is not in a form well-suited for analysis, and so we\n",
    "transform it. There are many reasons a feature might need a transformation: the\n",
    "value codings might not be useful for analysis; we may want to apply a mathematical function to\n",
    "a feature; or we might want to pull\n",
    "information out of a feature and create a new feature. We describe these three\n",
    "basic kinds of transformations: type conversions, mathematical transformations,\n",
    "and extractions.\n",
    "\n",
    "Type conversion\n",
    ": This kind of transformation occurs when we convert the\n",
    "data from one format to another to make the data more useful for analysis. We\n",
    "might convert information stored as a string to another format. For example, we\n",
    "would want to convert prices reported as strings to numeric (like changing the\n",
    "string `\"$2.17\"` to the number 2.17) so that we can compute summary statistics.\n",
    "Or we might want to convert a time stored as a string, such as\n",
    "`\"1955-10-12\"`, to a `pandas Timestamp` object. Yet another example occurs when we lump\n",
    "categories together, such as reducing the 11 categories for age in DAWN to 5\n",
    "groupings.     "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "Mathematical transformation\n",
    ": One kind of mathematical transformation is\n",
    "when we change the units of a measurement from, say, pounds to kilograms. We\n",
    "might make unit conversions so that statistics on our data can be directly\n",
    "compared to statistics on other datasets. Yet another reason to transform a feature is to\n",
    "make its distribution more symmetric (this notion is covered in more detail in {numref}`Chapter %s <ch:eda>`).\n",
    "The most common transformation for handling asymmetry is the logarithm. Lastly, we might want\n",
    "to create a new feature from arithmetic operations. For example,\n",
    "we can combine heights and weights to create body mass indexes by calculating\n",
    "$\\text{height} / \\text{weight}^2$. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "Extraction\n",
    ": Sometimes we want to create a feature by extraction, where the new feature contains\n",
    "partial information taken from another feature. For example, the inspection\n",
    "violations consist of strings with descriptions of violations, and we may only\n",
    "be interested in whether the violation is related to, say, vermin. We can\n",
    "create a new feature that is `True` if the violation contains the word _vermin_\n",
    "in its text description and `False` otherwise.  This conversion of information\n",
    "to logical values (or 0-1 values) is extremely useful in data science. The\n",
    "upcoming example in this chapter gives a concrete use-case for these binary features. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "We cover many other examples of useful transformations in {numref}`Chapter %s <ch:eda>`. \n",
    "For the rest of this section, we explain one more kind of transformation related to working with dates and times. \n",
    "Dates and times appear in many kinds of data, so it's worth learning how to work with\n",
    "these data types."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "## Transforming Timestamps"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "A *timestamp* is a data value that records a specific date and time.\n",
    "For instance, a timestamp could be recorded like `Jan 1 2020 2pm` or\n",
    "`2021-01-31 14:00:00` or `2017 Mar 03 05:12:41.211 PDT`.\n",
    "Timestamps come in many different formats! This kind of information can be useful for analysis, \n",
    "because it lets us answer questions like, \"What times of day do we have the most website traffic?\"\n",
    "When we work with timestamps, we often need to parse them for easier analysis.\n",
    "\n",
    "Let's take a look at an example. The inspections dataframe for the San Francisco restaurants\n",
    "includes the date when restaurant inspections happened:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>business_id</th>\n",
       "      <th>score</th>\n",
       "      <th>date</th>\n",
       "      <th>type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>94</td>\n",
       "      <td>20160513</td>\n",
       "      <td>routine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19</td>\n",
       "      <td>94</td>\n",
       "      <td>20171211</td>\n",
       "      <td>routine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>24</td>\n",
       "      <td>98</td>\n",
       "      <td>20171101</td>\n",
       "      <td>routine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>24</td>\n",
       "      <td>98</td>\n",
       "      <td>20161005</td>\n",
       "      <td>routine</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   business_id  score      date     type\n",
       "0           19     94  20160513  routine\n",
       "1           19     94  20171211  routine\n",
       "2           24     98  20171101  routine\n",
       "3           24     98  20161005  routine"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insp.head(4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "By default, however, `pandas` reads in the `date` column as an integer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('int64')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insp['date'].dtype"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "This storage type makes it hard to answer some useful questions about the data.\n",
    "Let's say we want to know whether  inspections happen more often on weekends or weekdays. \n",
    "To answer this question, we want to convert the `date` column to the `pandas` `Timestamp`\n",
    "storage type and extract the day of the week."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "The date values appear to come in the format `YYYYMMDD`, where `YYYY`,\n",
    "`MM`, and `DD` correspond to the four-digit year, two-digit month, and two-digit day, respectively.\n",
    "The `pd.to_datetime()` method can parse the date strings into objects, where\n",
    "we can pass in the format of the dates as a \n",
    "[date format](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) string:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0   2016-05-13\n",
       "1   2017-12-11\n",
       "2   2017-11-01\n",
       "Name: date, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date_format = '%Y%m%d'\n",
    "\n",
    "insp_dates = pd.to_datetime(insp['date'], format=date_format)\n",
    "insp_dates[:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "We can see that the `insp_dates` now has a `dtype` of `datetime64[ns]`, which\n",
    "means that the values were successfully converted into `pd.Timestamp` objects.[^datetimes]\n",
    "\n",
    "[^datetimes]: This `dtype` means that `pandas` uses 64 bits of memory for\n",
    "    each value and that each `datetime` is accurate to the nanosecond (or ns,\n",
    "    for short).\n",
    "\n",
    ":::{note}\n",
    "\n",
    "The `pd.to_datetime()` method tries to automatically infer the timestamp format\n",
    "if we don't pass in the `format=` argument. In many cases, `pandas` will parse\n",
    "the timestamps properly. However, sometimes the parsing doesn't output the\n",
    "correct timestamps (as in this case), so we must explicitly specify the\n",
    "format. \n",
    "\n",
    ":::\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "\n",
    "`pandas` has special methods and properties for `Series` objects\n",
    "that hold timestamps using the `.dt` accessor. For instance, we can easily pull\n",
    "out the year for each timestamp:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    2016\n",
       "1    2017\n",
       "2    2017\n",
       "Name: date, dtype: int32"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insp_dates.dt.year[:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "The `pandas` documentation has the complete details on the \n",
    "[`.dt` accessor](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#time-date-components). By\n",
    "looking at the documentation, \n",
    "we see that the `.dt.day_of_week` attribute gets the day of the week for each\n",
    "timestamp (Monday = 0, Tuesday = 1, ..., Sunday = 6).\n",
    "So let's assign new columns to the dataframe that contain both the parsed\n",
    "timestamps and the day of the week: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>business_id</th>\n",
       "      <th>score</th>\n",
       "      <th>date</th>\n",
       "      <th>type</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>dow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>94</td>\n",
       "      <td>20160513</td>\n",
       "      <td>routine</td>\n",
       "      <td>2016-05-13</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19</td>\n",
       "      <td>94</td>\n",
       "      <td>20171211</td>\n",
       "      <td>routine</td>\n",
       "      <td>2017-12-11</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>24</td>\n",
       "      <td>98</td>\n",
       "      <td>20171101</td>\n",
       "      <td>routine</td>\n",
       "      <td>2017-11-01</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   business_id  score      date     type  timestamp  dow\n",
       "0           19     94  20160513  routine 2016-05-13    4\n",
       "1           19     94  20171211  routine 2017-12-11    0\n",
       "2           24     98  20171101  routine 2017-11-01    2"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insp = insp.assign(timestamp=insp_dates,\n",
    "                   dow=insp_dates.dt.dayofweek)\n",
    "insp.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "Now we can see whether restaurant inspectors favor a certain day of the week\n",
    "by grouping on the day of the week:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>dow</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>3281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>3264</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2497</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>2464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>2101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>474</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5</td>\n",
       "      <td>141</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   dow  count\n",
       "0    2   3281\n",
       "1    1   3264\n",
       "2    3   2497\n",
       "3    0   2464\n",
       "4    4   2101\n",
       "5    6    474\n",
       "6    5    141"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insp['dow'].value_counts().reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "tags": [
     "hide-input"
    ]
   },
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "alignmentgroup": "True",
         "hovertemplate": "Inspection day=%{x}<br>count=%{y}<extra></extra>",
         "legendgroup": "",
         "marker": {
          "color": "#1F77B4",
          "pattern": {
           "shape": ""
          }
         },
         "name": "",
         "offsetgroup": "",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": [
          2,
          1,
          3,
          0,
          4,
          6,
          5
         ],
         "xaxis": "x",
         "y": [
          3281,
          3264,
          2497,
          2464,
          2101,
          474,
          141
         ],
         "yaxis": "y"
        }
       ],
       "layout": {
        "barmode": "relative",
        "height": 250,
        "legend": {
         "tracegroupgap": 0
        },
        "showlegend": false,
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "rgb(36,36,36)"
            },
            "error_y": {
             "color": "rgb(36,36,36)"
            },
            "marker": {
             "line": {
              "color": "white",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "white",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "rgb(36,36,36)",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "rgb(36,36,36)"
            },
            "baxis": {
             "endlinecolor": "rgb(36,36,36)",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "rgb(36,36,36)"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "colorscale": [
             [
              0,
              "#440154"
             ],
             [
              0.1111111111111111,
              "#482878"
             ],
             [
              0.2222222222222222,
              "#3e4989"
             ],
             [
              0.3333333333333333,
              "#31688e"
             ],
             [
              0.4444444444444444,
              "#26828e"
             ],
             [
              0.5555555555555556,
              "#1f9e89"
             ],
             [
              0.6666666666666666,
              "#35b779"
             ],
             [
              0.7777777777777778,
              "#6ece58"
             ],
             [
              0.8888888888888888,
              "#b5de2b"
             ],
             [
              1,
              "#fde725"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "colorscale": [
             [
              0,
              "#440154"
             ],
             [
              0.1111111111111111,
              "#482878"
             ],
             [
              0.2222222222222222,
              "#3e4989"
             ],
             [
              0.3333333333333333,
              "#31688e"
             ],
             [
              0.4444444444444444,
              "#26828e"
             ],
             [
              0.5555555555555556,
              "#1f9e89"
             ],
             [
              0.6666666666666666,
              "#35b779"
             ],
             [
              0.7777777777777778,
              "#6ece58"
             ],
             [
              0.8888888888888888,
              "#b5de2b"
             ],
             [
              1,
              "#fde725"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "colorscale": [
             [
              0,
              "#440154"
             ],
             [
              0.1111111111111111,
              "#482878"
             ],
             [
              0.2222222222222222,
              "#3e4989"
             ],
             [
              0.3333333333333333,
              "#31688e"
             ],
             [
              0.4444444444444444,
              "#26828e"
             ],
             [
              0.5555555555555556,
              "#1f9e89"
             ],
             [
              0.6666666666666666,
              "#35b779"
             ],
             [
              0.7777777777777778,
              "#6ece58"
             ],
             [
              0.8888888888888888,
              "#b5de2b"
             ],
             [
              1,
              "#fde725"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "line": {
              "color": "white",
              "width": 0.6
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "colorscale": [
             [
              0,
              "#440154"
             ],
             [
              0.1111111111111111,
              "#482878"
             ],
             [
              0.2222222222222222,
              "#3e4989"
             ],
             [
              0.3333333333333333,
              "#31688e"
             ],
             [
              0.4444444444444444,
              "#26828e"
             ],
             [
              0.5555555555555556,
              "#1f9e89"
             ],
             [
              0.6666666666666666,
              "#35b779"
             ],
             [
              0.7777777777777778,
              "#6ece58"
             ],
             [
              0.8888888888888888,
              "#b5de2b"
             ],
             [
              1,
              "#fde725"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "colorscale": [
             [
              0,
              "#440154"
             ],
             [
              0.1111111111111111,
              "#482878"
             ],
             [
              0.2222222222222222,
              "#3e4989"
             ],
             [
              0.3333333333333333,
              "#31688e"
             ],
             [
              0.4444444444444444,
              "#26828e"
             ],
             [
              0.5555555555555556,
              "#1f9e89"
             ],
             [
              0.6666666666666666,
              "#35b779"
             ],
             [
              0.7777777777777778,
              "#6ece58"
             ],
             [
              0.8888888888888888,
              "#b5de2b"
             ],
             [
              1,
              "#fde725"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 1,
              "tickcolor": "rgb(36,36,36)",
              "ticks": "outside"
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 1,
             "tickcolor": "rgb(36,36,36)",
             "ticks": "outside"
            },
            "colorscale": [
             [
              0,
              "#440154"
             ],
             [
              0.1111111111111111,
              "#482878"
             ],
             [
              0.2222222222222222,
              "#3e4989"
             ],
             [
              0.3333333333333333,
              "#31688e"
             ],
             [
              0.4444444444444444,
              "#26828e"
             ],
             [
              0.5555555555555556,
              "#1f9e89"
             ],
             [
              0.6666666666666666,
              "#35b779"
             ],
             [
              0.7777777777777778,
              "#6ece58"
             ],
             [
              0.8888888888888888,
              "#b5de2b"
             ],
             [
              1,
              "#fde725"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "rgb(237,237,237)"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "rgb(217,217,217)"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autosize": true,
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 1,
            "tickcolor": "rgb(36,36,36)",
            "ticks": "outside"
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "rgb(103,0,31)"
            ],
            [
             0.1,
             "rgb(178,24,43)"
            ],
            [
             0.2,
             "rgb(214,96,77)"
            ],
            [
             0.3,
             "rgb(244,165,130)"
            ],
            [
             0.4,
             "rgb(253,219,199)"
            ],
            [
             0.5,
             "rgb(247,247,247)"
            ],
            [
             0.6,
             "rgb(209,229,240)"
            ],
            [
             0.7,
             "rgb(146,197,222)"
            ],
            [
             0.8,
             "rgb(67,147,195)"
            ],
            [
             0.9,
             "rgb(33,102,172)"
            ],
            [
             1,
             "rgb(5,48,97)"
            ]
           ],
           "sequential": [
            [
             0,
             "#440154"
            ],
            [
             0.1111111111111111,
             "#482878"
            ],
            [
             0.2222222222222222,
             "#3e4989"
            ],
            [
             0.3333333333333333,
             "#31688e"
            ],
            [
             0.4444444444444444,
             "#26828e"
            ],
            [
             0.5555555555555556,
             "#1f9e89"
            ],
            [
             0.6666666666666666,
             "#35b779"
            ],
            [
             0.7777777777777778,
             "#6ece58"
            ],
            [
             0.8888888888888888,
             "#b5de2b"
            ],
            [
             1,
             "#fde725"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#440154"
            ],
            [
             0.1111111111111111,
             "#482878"
            ],
            [
             0.2222222222222222,
             "#3e4989"
            ],
            [
             0.3333333333333333,
             "#31688e"
            ],
            [
             0.4444444444444444,
             "#26828e"
            ],
            [
             0.5555555555555556,
             "#1f9e89"
            ],
            [
             0.6666666666666666,
             "#35b779"
            ],
            [
             0.7777777777777778,
             "#6ece58"
            ],
            [
             0.8888888888888888,
             "#b5de2b"
            ],
            [
             1,
             "#fde725"
            ]
           ]
          },
          "colorway": [
           "#1F77B4",
           "#FF7F0E",
           "#2CA02C",
           "#D62728",
           "#9467BD",
           "#8C564B",
           "#E377C2",
           "#7F7F7F",
           "#BCBD22",
           "#17BECF"
          ],
          "font": {
           "color": "rgb(36,36,36)"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "white",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "height": 250,
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "margin": {
           "b": 10,
           "l": 10,
           "r": 10,
           "t": 10
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "white",
          "polar": {
           "angularaxis": {
            "gridcolor": "rgb(232,232,232)",
            "linecolor": "rgb(36,36,36)",
            "showgrid": false,
            "showline": true,
            "ticks": "outside"
           },
           "bgcolor": "white",
           "radialaxis": {
            "gridcolor": "rgb(232,232,232)",
            "linecolor": "rgb(36,36,36)",
            "showgrid": false,
            "showline": true,
            "ticks": "outside"
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "white",
            "gridcolor": "rgb(232,232,232)",
            "gridwidth": 2,
            "linecolor": "rgb(36,36,36)",
            "showbackground": true,
            "showgrid": false,
            "showline": true,
            "ticks": "outside",
            "zeroline": false,
            "zerolinecolor": "rgb(36,36,36)"
           },
           "yaxis": {
            "backgroundcolor": "white",
            "gridcolor": "rgb(232,232,232)",
            "gridwidth": 2,
            "linecolor": "rgb(36,36,36)",
            "showbackground": true,
            "showgrid": false,
            "showline": true,
            "ticks": "outside",
            "zeroline": false,
            "zerolinecolor": "rgb(36,36,36)"
           },
           "zaxis": {
            "backgroundcolor": "white",
            "gridcolor": "rgb(232,232,232)",
            "gridwidth": 2,
            "linecolor": "rgb(36,36,36)",
            "showbackground": true,
            "showgrid": false,
            "showline": true,
            "ticks": "outside",
            "zeroline": false,
            "zerolinecolor": "rgb(36,36,36)"
           }
          },
          "shapedefaults": {
           "fillcolor": "black",
           "line": {
            "width": 0
           },
           "opacity": 0.3
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "rgb(232,232,232)",
            "linecolor": "rgb(36,36,36)",
            "showgrid": false,
            "showline": true,
            "ticks": "outside"
           },
           "baxis": {
            "gridcolor": "rgb(232,232,232)",
            "linecolor": "rgb(36,36,36)",
            "showgrid": false,
            "showline": true,
            "ticks": "outside"
           },
           "bgcolor": "white",
           "caxis": {
            "gridcolor": "rgb(232,232,232)",
            "linecolor": "rgb(36,36,36)",
            "showgrid": false,
            "showline": true,
            "ticks": "outside"
           }
          },
          "title": {
           "x": 0.5,
           "xanchor": "center"
          },
          "width": 350,
          "xaxis": {
           "automargin": true,
           "gridcolor": "rgb(232,232,232)",
           "linecolor": "rgb(36,36,36)",
           "showgrid": true,
           "showline": true,
           "ticks": "outside",
           "title": {
            "standoff": 15
           },
           "zeroline": false,
           "zerolinecolor": "rgb(36,36,36)"
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "rgb(232,232,232)",
           "linecolor": "rgb(36,36,36)",
           "showgrid": true,
           "showline": true,
           "ticks": "outside",
           "title": {
            "standoff": 15
           },
           "zeroline": false,
           "zerolinecolor": "rgb(36,36,36)"
          }
         }
        },
        "width": 350,
        "xaxis": {
         "anchor": "y",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "range": [
          -0.5,
          6.5
         ],
         "ticktext": [
          "Mon",
          "Tue",
          "Wed",
          "Thu",
          "Fri",
          "Sat",
          "Sun"
         ],
         "tickvals": [
          0,
          1,
          2,
          3,
          4,
          5,
          6
         ],
         "title": {
          "text": "Inspection day"
         },
         "type": "linear"
        },
        "yaxis": {
         "anchor": "x",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "range": [
          0,
          3453.684210526316
         ],
         "title": {
          "text": "count"
         },
         "type": "linear"
        }
       }
      },
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdsAAAD6CAYAAADp/e0TAAAAAXNSR0IArs4c6QAAIABJREFUeF7tnQeUFUX69t8hDDlnFVFAWCWKI0FFBWUF3D0gSJKwZBBcQFFcXY4KKMmwayAKCoYFVl0WA6hIkiBZJYkSJIggA0ieIX/nqf33/WaGO3O7eqrr9r08dc4cuPdWvVX11Nv967equjvh0qVLl4SJClABKkAFqAAV8E2BBMLWN21pmApQASpABaiAUoCwpSNQASpABagAFfBZAcLWZ4FpngpQASpABagAYUsfoAJUgApQASrgswKErc8C0zwVoAJUgApQAcKWPkAFqAAVoAJUwGcFCFufBaZ5KkAFqAAVoAKELX2AClABKkAFqIDPChC2PgtM81SAClABKkAFCNtMfOCGG26Qbdu2WfOQ1NRUOXPmjBQpUsRanTYrwoPKkpOTpXTp0jartVrX4cOH1fjlypXLar22Kjt16pRgHAsWLGirSqv1nDt3Tk6cOCHFixe3Wq/Nyg4ePCilSpWShIQEm9Vaq+vYsWOSJ08eyZs3r7U63VZE2BK2bn0lW/kI22zJF4jChG0ghiFbjSBssyVftgoTtoRtthzIbWHC1q1Swc1H2AZ3bNy2jLB1q5T5fIQtYWveq8JYJGytyOxrJYStr/JaMU7YWpE5bCWELWFrxfsIWysy+1oJYeurvFaME7ZWZCZsdWTmBikdtSLnJWwjaxT0HIRt0EcocvsI28ga+ZWDkS0jW798K51dwtaKzL5WQtj6Kq8V44StFZkZ2erIzMhWR63IeQnbyBoFPQdhG/QRitw+wjayRn7lYGTLyNYv37riIlvc44d7UHPmzGlFU9uVELa2FTdfH2FrXlO3Fglbwtatr2Q739GjR6Vo0aLZ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rAlbPWPG6slCFvC1pTDEbamlNS3Q9gStoSt/nFjtQRhS9iacjjC1pSS+nYIW8KWsNU/bqyWIGwJW1MOR9iaUlLfDmFL2BK2+seN1RKELWFryuEIW1NK6tshbAlbwlb/uLFagrAlbE05HGFrSkl9O4QtYUvY6h83VksQtoStKYcjbE0pqW+HsCVsCVv948ZqCcLiWQHIAAAaDklEQVSWsDXlcIStKSX17RC2hC1hq3/cWC1B2BK2phyOsDWlpL4dwpawJWz1jxurJQhbwtaUwxG2ppTUt0PYEraErf5xY7UEYUvYmnI4wtaUkvp2CFvClrDVP26sliBsCVtTDkfYmlJS3w5hS9gStvrHjdUShC1ha8rhCFtTSurbIWwJW8JW/7ixWoKwJWxNORxha0pJfTuELWFL2OofN1ZLELaErSmHI2xNKalvh7AlbAlb/ePGagnClrA15XCErSkl9e0QtoQtYat/3FgtQdgStqYcjrA1paS+HcKWsCVs9Y8bqyUIW8LWlMPFO2xPnjwpiYmJ6i9oibAlbAnboB2VGdpD2BK2plw0KLD9ZudhWbnjsKluhexcuHhREhISJEdCglHbiTlzSNMaZaVSqYKe7RK2hC1h6/nwsVOQsCVsTXlaUGA7a80eefKjjaa65budwvlyyzvd60rt8kU910XYEraErefDx05BwpawNeVphK03JQlbb7q5KnXDDTfItm3bLsv73d6j0mXqKjmeet6VnSBkGvtgTWmbVN5VU46lnJNOU1bJxn3HXOUPQqam1crIxM5Jrpsy5vOtMmHxDtf5o52RsCVsTfkgYetNScLWm26uShG2hK0rR7GQibAlbE25GWHrTUnC1pturkoRtoStK0exkImwJWxNuRlh601Jwtabbq5KEbaErStHsZCJsCVsTbkZYetNScLWm26uShG2hK0rR7GQibAlbE25GWHrTUnC1pturkoRtoStK0exkImwJWxNuRlh601Jwtabbq5KEbaErStHsZCJsCVsTbkZYetNScLWm26uShG2hK0rR7GQibAlbE25GWHrTUnC1pturkoRtoStK0exkImwJWxNuRlh601Jwtabbq5KEbaErStHsZCJsCVsTbkZYetNScLWm26uShG2hK0rR7GQib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GTZsYXob0ToTFYiGAoRtNFRnnVTAgAJYl8RmHz6cIWsxX331VcGtRohqnft1DchPE1RASwHCVksuZqYCVIAKUAEqoK8AYauvGUtQASpABagAFdBSgLDVkouZqQAVoAJUgAroK0DY6mvGElSAClABKkAFtBQgbLXkYmYqQAWoABWgAvoKELb6mrEEFaACVIAKUAEtBQhbLbmYmQpQASpABaiAvgKErb5mLEEFqAAVoAJUQEuB/wcoRwk9OaRIkwAAAABJRU5ErkJggg==",
      "image/svg+xml": [
       "<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"350\" height=\"250\" style=\"\" viewBox=\"0 0 350 250\"><rect x=\"0\" y=\"0\" width=\"350\" height=\"250\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-26f4d0\"><g class=\"clips\"><clipPath id=\"clip26f4d0xyplot\" class=\"plotclip\"><rect width=\"266\" height=\"182\"/></clipPath><clipPath class=\"axesclip\" id=\"clip26f4d0x\"><rect x=\"74\" y=\"0\" width=\"266\" height=\"250\"/></clipPath><clipPath class=\"axesclip\" id=\"clip26f4d0y\"><rect x=\"0\" y=\"10\" width=\"350\" height=\"182\"/></clipPath><clipPath class=\"axesclip\" id=\"clip26f4d0xy\"><rect x=\"74\" y=\"10\" width=\"266\" height=\"182\"/></clipPath></g><g class=\"gradients\"/><g class=\"patterns\"/></defs><g class=\"bglayer\"/><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"minor-gridlayer\"><g class=\"x\"/><g class=\"y\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(93,0)\" d=\"M0,10v182\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(131,0)\" d=\"M0,10v182\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(169,0)\" d=\"M0,10v182\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(207,0)\" d=\"M0,10v182\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(245,0)\" d=\"M0,10v182\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(283,0)\" d=\"M0,10v182\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(321,0)\" d=\"M0,10v182\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,139.3)\" d=\"M74,0h266\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"ygrid crisp\" transform=\"translate(0,86.61)\" d=\"M74,0h266\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"ygrid crisp\" transform=\"translate(0,33.91)\" d=\"M74,0h266\" style=\"stroke: rgb(232, 232, 232); stroke-opacity: 1; stroke-width: 1px;\"/></g></g><g class=\"zerolinelayer\"/><path class=\"xlines-below\"/><path class=\"ylines-below\"/><g class=\"overlines-below\"/><g class=\"xaxislayer-below\"/><g class=\"yaxislayer-below\"/><g class=\"overaxes-below\"/><g class=\"plot\" transform=\"translate(74,10)\" clip-path=\"url(#clip26f4d0xyplot)\"><g class=\"barlayer mlayer\"><g class=\"trace bars\" style=\"opacity: 1;\"><g class=\"points\"><g class=\"point\"><path d=\"M79.8,182V9.1H110.2V182Z\" style=\"vector-effect: none; opacity: 1; stroke-width: 0.5px; fill: rgb(31, 119, 180); fill-opacity: 1; stroke: rgb(255, 255, 255); stroke-opacity: 1;\"/></g><g class=\"point\"><path d=\"M41.8,182V10H72.2V182Z\" style=\"vector-effect: none; opacity: 1; stroke-width: 0.5px; fill: rgb(31, 119, 180); fill-opacity: 1; stroke: rgb(255, 255, 255); stroke-opacity: 1;\"/></g><g class=\"point\"><path d=\"M117.8,182V50.41H148.2V182Z\" style=\"vector-effect: none; opacity: 1; stroke-width: 0.5px; fill: rgb(31, 119, 180); fill-opacity: 1; stroke: rgb(255, 255, 255); stroke-opacity: 1;\"/></g><g class=\"point\"><path d=\"M3.8,182V52.15H34.2V182Z\" style=\"vector-effect: none; opacity: 1; stroke-width: 0.5px; fill: rgb(31, 119, 180); fill-opacity: 1; stroke: rgb(255, 255, 255); stroke-opacity: 1;\"/></g><g class=\"point\"><path d=\"M155.8,182V71.28H186.2V182Z\" style=\"vector-effect: none; opacity: 1; stroke-width: 0.5px; fill: rgb(31, 119, 180); fill-opacity: 1; stroke: rgb(255, 255, 255); stroke-opacity: 1;\"/></g><g class=\"point\"><path d=\"M231.8,182V157.02H262.2V182Z\" style=\"vector-effect: none; opacity: 1; stroke-width: 0.5px; fill: rgb(31, 119, 180); fill-opacity: 1; stroke: rgb(255, 255, 255); stroke-opacity: 1;\"/></g><g class=\"point\"><path d=\"M193.8,182V174.57H224.2V182Z\" style=\"vector-effect: none; opacity: 1; stroke-width: 0.5px; fill: rgb(31, 119, 180); fill-opacity: 1; stroke: rgb(255, 255, 255); stroke-opacity: 1;\"/></g></g></g></g></g><g class=\"overplot\"/><path class=\"xlines-above crisp\" d=\"M73,192.5H340\" style=\"fill: none; stroke-width: 1px; stroke: rgb(36, 36, 36); stroke-opacity: 1;\"/><path class=\"ylines-above crisp\" d=\"M73.5,10V192\" style=\"fill: none; stroke-width: 1px; stroke: rgb(36, 36, 36); stroke-opacity: 1;\"/><g class=\"overlines-above\"/><g class=\"xaxislayer-above\"><path class=\"xtick ticks crisp\" d=\"M0,193v5\" transform=\"translate(93,0)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xtick ticks crisp\" d=\"M0,193v5\" transform=\"translate(131,0)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xtick ticks crisp\" d=\"M0,193v5\" transform=\"translate(169,0)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xtick ticks crisp\" d=\"M0,193v5\" transform=\"translate(207,0)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xtick ticks crisp\" d=\"M0,193v5\" transform=\"translate(245,0)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xtick ticks crisp\" d=\"M0,193v5\" transform=\"translate(283,0)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xtick ticks crisp\" d=\"M0,193v5\" transform=\"translate(321,0)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"212.4\" transform=\"translate(93,0)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\">Mon</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"212.4\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(131,0)\">Tue</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"212.4\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(169,0)\">Wed</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"212.4\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(207,0)\">Thu</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"212.4\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(245,0)\">Fri</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"212.4\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(283,0)\">Sat</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"212.4\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(321,0)\">Sun</text></g></g><g class=\"yaxislayer-above\"><path class=\"ytick ticks crisp\" d=\"M73,0h-5\" transform=\"translate(0,192)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"ytick ticks crisp\" d=\"M73,0h-5\" transform=\"translate(0,139.3)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"ytick ticks crisp\" d=\"M73,0h-5\" transform=\"translate(0,86.61)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"ytick ticks crisp\" d=\"M73,0h-5\" transform=\"translate(0,33.91)\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/><g class=\"ytick\"><text text-anchor=\"end\" x=\"65.6\" y=\"4.199999999999999\" transform=\"translate(0,192)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\">0</text></g><g class=\"ytick\"><text text-anchor=\"end\" x=\"65.6\" y=\"4.199999999999999\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(0,139.3)\">1000</text></g><g class=\"ytick\"><text text-anchor=\"end\" x=\"65.6\" y=\"4.199999999999999\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(0,86.61)\">2000</text></g><g class=\"ytick\"><text text-anchor=\"end\" x=\"65.6\" y=\"4.199999999999999\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(36, 36, 36); fill-opacity: 1; white-space: pre; opacity: 1;\" transform=\"translate(0,33.91)\">3000</text></g></g><g class=\"overaxes-above\"/></g></g><g class=\"polarlayer\"/><g class=\"smithlayer\"/><g class=\"ternarylayer\"/><g class=\"geolayer\"/><g class=\"funnelarealayer\"/><g class=\"pielayer\"/><g class=\"iciclelayer\"/><g class=\"treemaplayer\"/><g class=\"sunburstlayer\"/><g class=\"glimages\"/><defs id=\"topdefs-26f4d0\"><g class=\"clips\"/></defs><g class=\"layer-above\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"infolayer\"><g class=\"g-gtitle\"/><g class=\"g-xtitle\"><text class=\"xtitle\" x=\"207\" y=\"239.20625\" text-anchor=\"middle\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 14px; fill: rgb(36, 36, 36); opacity: 1; font-weight: normal; white-space: pre;\">Inspection day</text></g><g class=\"g-ytitle\" transform=\"translate(3.2216796875,0)\"><text class=\"ytitle\" transform=\"rotate(-90,10.778125000000003,101)\" x=\"10.778125000000003\" y=\"101\" text-anchor=\"middle\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 14px; fill: rgb(36, 36, 36); opacity: 1; font-weight: normal; white-space: pre;\">count</text></g></g></svg>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "day = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']\n",
    "fig = px.bar(insp['dow'].value_counts().reset_index(),\n",
    "             x='dow', y='count',\n",
    "             labels={'dow':'Inspection day'},\n",
    "             height=250, width=350)\n",
    "fig.update_xaxes(ticktext=day, tickvals=np.arange(0, 7, 1))\n",
    "fig.update_layout(showlegend=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "As expected, inspections rarely happen on the weekend. We also find that Tuesday and Wednesday are the most popular days for an inspection. \n",
    "\n",
    "We have performed many wranglings on the inspections table. One approach to tracking these modifications is to pipe these actions from one to the next. We describe the idea of piping next."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "## Piping for Transformations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "In data analyses, we typically apply many transformations to the data, and\n",
    "it is easy to introduce bugs when we repeatedly mutate a dataframe,\n",
    "in part because Jupyter notebooks let us run cells in any order we want. As a good\n",
    "practice, we recommend putting transformation code into functions with helpful\n",
    "names and using the `DataFrame.pipe()` method to chain transformations\n",
    "together.\n",
    "\n",
    "Let's rewrite the earlier timestamp parsing code into a function and\n",
    "add the timestamps back into the dataframe as a new column, along with \n",
    "a second column containing the year of the timestamp:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "date_format = '%Y%m%d'\n",
    "\n",
    "def parse_dates_and_years(df, column='date'):\n",
    "    dates = pd.to_datetime(df[column], format=date_format)\n",
    "    years = dates.dt.year\n",
    "    return df.assign(timestamp=dates, year=years)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "Now we can pipe the `insp` dataframe through this function using `.pipe()`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "insp = (pd.read_csv(\"data/inspections.csv\")\n",
    "        .pipe(parse_dates_and_years))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "We can chain many `.pipe()` calls together. For example, we can extract the day of the week from the timestamps:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>business_id</th>\n",
       "      <th>score</th>\n",
       "      <th>date</th>\n",
       "      <th>type</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>year</th>\n",
       "      <th>dow</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>94</td>\n",
       "      <td>20160513</td>\n",
       "      <td>routine</td>\n",
       "      <td>2016-05-13</td>\n",
       "      <td>2016</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19</td>\n",
       "      <td>94</td>\n",
       "      <td>20171211</td>\n",
       "      <td>routine</td>\n",
       "      <td>2017-12-11</td>\n",
       "      <td>2017</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>24</td>\n",
       "      <td>98</td>\n",
       "      <td>20171101</td>\n",
       "      <td>routine</td>\n",
       "      <td>2017-11-01</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14219</th>\n",
       "      <td>94142</td>\n",
       "      <td>100</td>\n",
       "      <td>20171220</td>\n",
       "      <td>routine</td>\n",
       "      <td>2017-12-20</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14220</th>\n",
       "      <td>94189</td>\n",
       "      <td>96</td>\n",
       "      <td>20171130</td>\n",
       "      <td>routine</td>\n",
       "      <td>2017-11-30</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14221</th>\n",
       "      <td>94231</td>\n",
       "      <td>85</td>\n",
       "      <td>20171214</td>\n",
       "      <td>routine</td>\n",
       "      <td>2017-12-14</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>14222 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       business_id  score      date     type  timestamp  year  dow\n",
       "0               19     94  20160513  routine 2016-05-13  2016    4\n",
       "1               19     94  20171211  routine 2017-12-11  2017    0\n",
       "2               24     98  20171101  routine 2017-11-01  2017    2\n",
       "...            ...    ...       ...      ...        ...   ...  ...\n",
       "14219        94142    100  20171220  routine 2017-12-20  2017    2\n",
       "14220        94189     96  20171130  routine 2017-11-30  2017    3\n",
       "14221        94231     85  20171214  routine 2017-12-14  2017    3\n",
       "\n",
       "[14222 rows x 7 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def extract_day_of_week(df, col='timestamp'):\n",
    "    return df.assign(dow=df[col].dt.day_of_week)\n",
    "\n",
    "insp = (pd.read_csv(\"data/inspections.csv\")\n",
    "        .pipe(parse_dates_and_years)\n",
    "        .pipe(extract_day_of_week))\n",
    "insp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "user_expressions": []
   },
   "source": [
    "There are several key advantages of using `pipe()`. When there are many\n",
    "transformations on a single dataframe, it's easier to see what transformations\n",
    "happen since we can simply read the function names. Also, we can reuse\n",
    "transformation functions for different dataframes. For instance, the `viol`\n",
    "dataframe, which contains restaurant safety violations, also has a `date`\n",
    "column.\n",
    "This means we can use `.pipe()` to reuse the timestamp parsing function without\n",
    "needing to write extra code. Convenient!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>business_id</th>\n",
       "      <th>date</th>\n",
       "      <th>description</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>20171211</td>\n",
       "      <td>Inadequate food safety knowledge or lack of ce...</td>\n",
       "      <td>2017-12-11</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19</td>\n",
       "      <td>20171211</td>\n",
       "      <td>Unapproved or unmaintained equipment or utensils</td>\n",
       "      <td>2017-12-11</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   business_id      date                                        description  \\\n",
       "0           19  20171211  Inadequate food safety knowledge or lack of ce...   \n",
       "1           19  20171211   Unapproved or unmaintained equipment or utensils   \n",
       "\n",
       "   timestamp  year  \n",
       "0 2017-12-11  2017  \n",
       "1 2017-12-11  2017  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "viol = (pd.read_csv(\"data/violations.csv\")\n",
    "        .pipe(parse_dates_and_years)) \n",
    "viol.head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": [],
    "user_expressions": []
   },
   "source": [
    "A different sort of transformation changes the shape of a dataframe by dropping unneeded columns, taking a subset of the rows, or rolling up the rows to a coarser granularity. We describe these structural changes next. "
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
